<title>清理缓存</title>
<div class="layui-fluid">

	<div class="layui-bg-gray" style="padding: 30px;">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md3">
				<div class="layui-panel">
					<div class="addon-name">全部缓存</div>
					<div style="padding: 10px 30px; font-size: 12px; text-align: right;">
						<button type="button" class="layui-btn layui-btn-xs layui-btn-primary clear-cache-btn" data-tag="all">点击清理</button>
					</div>
				</div>
			</div>
			<div class="layui-col-md3">
				<div class="layui-panel">
					<div class="addon-name">插件缓存</div>
					<div style="padding: 10px 30px; font-size: 12px; text-align: right;">
						<button type="button" class="layui-btn layui-btn-xs layui-btn-primary clear-cache-btn" data-tag="addon">点击清理</button>
					</div>
				</div>
			</div>
			<div class="layui-col-md3">
				<div class="layui-panel">
					<div class="addon-name">配置缓存</div>
					<div style="padding: 10px 30px; font-size: 12px; text-align: right;">
						<button type="button" class="layui-btn layui-btn-xs layui-btn-primary clear-cache-btn" data-tag="config">点击清理</button>
					</div>
				</div>
			</div>
			<div class="layui-col-md3">
				<div class="layui-panel">
					<div class="addon-name">后台登录缓存</div>
					<div style="padding: 10px 30px; font-size: 12px; text-align: right;">
						<button type="button" class="layui-btn layui-btn-xs layui-btn-primary clear-cache-btn" data-tag="admin_login_token">点击清理</button>
					</div>
				</div>
			</div>
			<div class="layui-col-md3">
				<div class="layui-panel">
					<div class="addon-name">前端用户登录缓存</div>
					<div style="padding: 10px 30px; font-size: 12px; text-align: right;">
						<button type="button" class="layui-btn layui-btn-xs layui-btn-primary clear-cache-btn" data-tag="member_token">点击清理</button>
					</div>
				</div>
			</div>
		</div>
	</div>

</div>
<script>
	layui.use(['form', 'table'], function() {
		var $ = layui.jquery,
			form = layui.form,
			table = layui.table;

		$(document).on("click", ".clear-cache-btn", function() {
			let _tag = $(this).data('tag');

			layer.confirm('确定清理缓存？', function() {
				layui.admin.req({
					url: layui.setter.API_HOST + 'admin/common/clear_cache',
					type: 'post',
					data: {
						'tag': _tag
					},
					done: function(res) {
						if (res.code == 0) {
							layer.msg('清理成功', {item: 1});
						} else {
							layer.msg('操作失败', {item: 5});
						}
					}
				});
			});
		});
	});
</script>
